<!DOCTYPE html>
<html>
<head>
    <title>Physics Diagram</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }
        canvas {
            border: 1px solid #ccc;
            background-color: #fff;
        }
    </style>
</head>
<body>

<canvas id="physicsCanvas" width="650" height="400"></canvas>

<script>
    const canvas = document.getElementById('physicsCanvas');
    const ctx = canvas.getContext('2d');

    // --- Style settings ---
    ctx.strokeStyle = 'black';
    ctx.fillStyle = 'black';
    ctx.lineWidth = 2.5;
    // A font that mimics a handwritten style
    ctx.font = "24px 'Comic Sans MS', 'Chalkduster', cursive";
    ctx.textBaseline = 'middle';
    ctx.textAlign = 'left';

    // --- Main container ---
    const containerX = 75;
    const containerY = 75;
    const containerWidth = 350;
    const containerHeight = 150;
    ctx.strokeRect(containerX, containerY, containerWidth, containerHeight);

    // --- Phase boundary ---
    const boundaryY = containerY + containerHeight * 0.4;
    ctx.beginPath();
    ctx.moveTo(containerX, boundaryY);
    ctx.lineTo(containerX + containerWidth, boundaryY);
    ctx.stroke();

    // --- Dilute phase dots ---
    const diluteTop = boundaryY;
    const diluteBottom = containerY + containerHeight;
    const diluteLeft = containerX;
    const diluteRight = containerX + containerWidth;
    const numDots = 250;
    for (let i = 0; i < numDots; i++) {
        // Ensure dots don't touch the boundaries for a cleaner look
        const dotX = Math.random() * (diluteRight - diluteLeft - 10) + diluteLeft + 5;
        const dotY = Math.random() * (diluteBottom - diluteTop - 10) + diluteTop + 5;
        const radius = 1 + Math.random() * 1; // Vary dot size slightly
        ctx.beginPath();
        ctx.arc(dotX, dotY, radius, 0, 2 * Math.PI);
        ctx.fill();
    }

    // --- Labels and lines ---
    const labelX = containerX + containerWidth + 25;

    // Concentrated phase label
    // Using Unicode for superscripts: ³ is U+00B3
    const concentratedText = "concentrated phase of \u00B3He";
    const concentratedLabelY = containerY + (boundaryY - containerY) / 2;
    ctx.fillText(concentratedText, labelX, concentratedLabelY);
    ctx.beginPath();
    ctx.moveTo(labelX - 10, concentratedLabelY);
    ctx.lineTo(containerX + containerWidth, concentratedLabelY);
    ctx.stroke();

    // Dilute phase label
    // Using Unicode for superscripts: ³ is U+00B3, ⁴ is U+2074
    const diluteText1 = "dilute phase of \u00B3He";
    const diluteText2 = "(in superfluid of \u2074He)";
    const diluteLabelCenterY = boundaryY + (diluteBottom - boundaryY) / 2;
    ctx.fillText(diluteText1, labelX, diluteLabelCenterY - 15);
    ctx.fillText(diluteText2, labelX, diluteLabelCenterY + 15);
    ctx.beginPath();
    ctx.moveTo(labelX - 10, diluteLabelCenterY);
    ctx.lineTo(containerX + containerWidth, diluteLabelCenterY);
    ctx.stroke();

    // --- Figure Caption ---
    const captionX = containerX + containerWidth / 2;
    const captionY = containerY + containerHeight + 60;
    ctx.textAlign = 'center';
    ctx.fillText("Fig. 2.23.", captionX, captionY);
</script>

</body>
</html>